package na.learn.java.threads;

import java.io.File;

public class FileManagerImpl implements FileManager {
	public static String EXTN = "dll";

	/* (non-Javadoc)
	 * @see na.learn.java.threads.FileManager#recursivelyAddExtention(java.io.File)
	 */
	public boolean recursivelyAddExtention(File file) {

		if (file.isFile())
			file.renameTo(new File(file.getAbsolutePath() + "dll"));
		else if (file.isDirectory()) {

			for (File files : file.listFiles())
				recursivelyAddExtention(files);
		}

		return true;
	}
	
	
	/* (non-Javadoc)
	 * @see na.learn.java.threads.FileManager#recursivelyRemoveExtention(java.io.File)
	 */
	public  boolean recursivelyRemoveExtention(File file) {

		if (file.isFile())
		{
			String newFileName = file.getAbsolutePath().substring(0,file.getAbsolutePath().length()-3);
			file.renameTo(new File(newFileName));
		}
		else if (file.isDirectory()) {

			for (File files : file.listFiles())
				recursivelyRemoveExtention(files);
		}

		return true;
	}

	

}
